#include "MemoryPCH.h"

#include "MM_MemoryDefaultAllocPolicy.h"

using namespace Memory;
//----------------------------------------------------------------------------
//MM_MemoryDefaultAllocPolicy
//----------------------------------------------------------------------------
void* MM_MemoryDefaultAllocPolicy::allocBytes(size_t count)
{
	void* ptr = malloc(count);

	return ptr;
}
//---------------------------------------------------------------------
void* MM_MemoryDefaultAllocPolicy::allocBytesAligned(size_t count,size_t align)
{
	// default to platform SIMD alignment if none specified
	void* ptr = _aligned_malloc(align, count);

	return ptr;
}
//---------------------------------------------------------------------
void* MM_MemoryDefaultAllocPolicy::reallocBytes(void* ptr ,size_t count)
{
	void* newPtr = realloc( ptr , count );

	return newPtr;
}
//---------------------------------------------------------------------
void* MM_MemoryDefaultAllocPolicy::reallocBytesAligned(void* ptr , size_t count ,size_t align)
{
	void* newPtr = _aligned_realloc( ptr , count,align );

	return newPtr;
}
//---------------------------------------------------------------------
void MM_MemoryDefaultAllocPolicy::deallocBytes(void* ptr)
{
	// deal with null
	if (!ptr)
		return;

	free(ptr);
}
//---------------------------------------------------------------------
void MM_MemoryDefaultAllocPolicy::deallocBytesAligned(void* ptr,size_t align)
{
	// deal with null
	if (!ptr)
		return;

	_aligned_free(ptr);
}